/**
 * Created by ZFL on 2017/12/26.
 */

function PageInit() {
    if(com_obj.userId && com_obj.userId>0){
        $(".user-me").show();
        userInfo();
    }
}

//查询用户信息
function userInfo() {
    $.ajaxHandler({
        model: function () {
            var obj = {};
            obj.userId = com_obj.userId;
            return obj;
        },
        visibleTime: 100,
        api: "yg_baijiaapp/user/getUserEntityByIdNoPassword",
        success: function (result) {
            //console.log(result);
            if (result.code == 10000) {
                var data = result.data;
                $("#nick-name").text(data.nickName);
                if (data.picture.toString().indexOf("http:") > -1) {
                    $(".user-head").attr("src", "" + data.picture + "");
                } else {
                    $(".user-head").attr("src", "" + $.imgApi() + "" + data.picture + "");
                }
                $("#phone-id").text(data.userName);

            } else if (result.code == 29901) {
                YDUI.dialog.toast("无效参数",'error',1000);
            } else if (result.code == 20113) {
                YDUI.dialog.toast("此用户不存在",'error',1000);
            } else if (result.code == 20120) {
                YDUI.dialog.toast("该用户已被锁定",1000);
            } else {
                YDUI.dialog.toast("查询失败",'error',1000);
            }
        }
    });
}

function  closeCache() {
    $.delStorage("hx_wx");
    $.delStorage('recommended')
    $.delStorage("xm_uData");
    $.delStorage('xmOpenid');
    $.delStorage('returnWxpay')
    $.delStorage('openUrl');
    $.delStorage("hx_AccessTokenIndex");
    $.delStorage("wx");
    $.delStorage("uData");
    $.delStorage("AccessTokenIndex");
    window.location.href='user_login.html';

    //$.delCookie("hx_wx");
    //$.delCookie("xm_uData");
    //$.delCookie("hx_AccessTokenIndex");
    //$.delCookie("wx");
    //$.delCookie("uData");
    //$.delCookie("AccessTokenIndex");
    //window.location.href='user_login.html';

}